<template>
    <div>
        {{ name }}-{{ age }}
    </div>
</template>

<script setup>
import { ref, watch } from 'vue';

let name = ref('张三');
let age = ref(22);

watch([name, age],
    ([nameNewValue, ageNewValue], [nameOldValue, ageOldValue]) => {
        console.log('name and age newValue');
        console.log(nameNewValue, ageNewValue);
        console.log('name and age oldValue');
        console.log(nameOldValue, ageOldValue);
    })

setTimeout(() => {
    name.value = '李四';
}, 1000);
setTimeout(() => {
    age.value = 33;
}, 2000);
</script>
